<!doctype html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">

<head>
    <meta charset="UTF-8"/>
    <title>会员管理</title>
    <META HTTP-EQUIV="Pragma" CONTENT="no-cache">
    <META HTTP-EQUIV="Cache-Control" CONTENT="no-cache">
    <META HTTP-EQUIV="Expires" CONTENT="0">
    <meta name="viewport"
          content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no"/>
    <link rel="stylesheet" th:href="@{/static/css/bootstrap.css}"/>
    <link rel="stylesheet" type="text/css" th:href="@{/static/css/font-awesome.min.css}"/>
    <link rel="stylesheet" type="text/css" th:href="@{/static/css/theme.css}"/>
    <link rel="stylesheet" th:href="@{/static/css/index.css}"/>
    <script th:src="@{/static/js/jquery.min.js}" type="text/javascript"></script>
    <script type="text/javascript" th:src="@{/static/js/bootstrap.js}"></script>
    <script th:src="@{/static/js/app.js}" type="text/javascript" charset="utf-8"></script>
</head>

<body>

<body>
<section class="body">

    <!-- start: header -->
    <header class="header">
        <div class="logo-container">
            <a href="" class="logo">
                <h1>管理员后台</h1>
            </a>
            <div class="visible-xs toggle-sidebar-left">
                <i class="fa fa-bars"></i>
            </div>
        </div>

        <!-- start: user box -->
        <div class="header-right">

            <span class="separator"></span>

            <div id="userbox" class="userbox">
                <a href="#" data-toggle="dropdown">
                    <figure class="profile-picture">
                        <img th:src="@{/static/imgs/avator.png}" alt="名字" class="img-circle"/>
                    </figure>
                    <div class="profile-info">
                        <span class="name">张三</span>
                        <span class="role">超级管理员</span>
                    </div>

                    <i class="fa custom-caret"></i>
                </a>

                <div class="dropdown-menu">
                    <ul class="list-unstyled">
                        <li class="divider"></li>
                        <li>
                            <a role="menuitem" href="#"><i class="fa fa-user"></i>个人中心</a>
                        </li>
                        <li>
                            <a role="menuitem" href="#"><i class="fa fa-gear"></i>系统设置</a>
                        </li>
                        <li>
                            <a role="menuitem" href="/admin/outLogin"><i class="fa fa-sign-out"></i>退出登录</a>
                        </li>
                    </ul>
                </div>
            </div>
        </div>

    </header>
    <!-- end: header -->

    <div class="inner-wrapper">
        <!-- start: sidebar -->
        <aside id="sidebar-left" class="sidebar-left">

            <div class="nano">
                <div class="nano-content">
                    <nav id="menu" class="nav-main" role="navigation">
                        <ul class="nav nav-main">
                            <li class="nav-active">
                                <a href="/admin/">
                                    <i class="fa fa-home" aria-hidden="true"></i>
                                    <span>首页</span>
                                </a>
                            </li>
                            <li class="nav-active">
                                <a href="/admin/getUsers?current=1">
                                    <i class="fa fa-users" aria-hidden="true"></i>
                                    <span>会员管理</span>
                                </a>
                            </li>
                            <li class="nav-active">
                                <a href="/admin/recharge?current=1">
                                    <i class="fa fa-credit-card" aria-hidden="true"></i>
                                    <span>充币管理</span>
                                </a>
                            </li>
                            <li class="nav-active">
                                <a href="/admin/withdraw?current=1">
                                    <i class="fa fa-usd" aria-hidden="true"></i>
                                    <span>提币管理</span>
                                </a>
                            </li>
                            <li class="nav-active">
                                <a href="/admin/goods?current=1">
                                    <i class="fa fa-shopping-cart" aria-hidden="true"></i>
                                    <span>商品管理</span>
                                </a>
                            </li>
<!--                            <li class="nav-active">-->
<!--                                <a href="/admin/vipSetting">-->
<!--                                    <i class="fa fa-trophy" aria-hidden="true"></i>-->
<!--                                    <span>VIP管理</span>-->
<!--                                </a>-->
<!--                            </li>-->
                            <li class="nav-active">
                                <a href="/admin/taskArea">
                                    <i class="fa fa-tasks" aria-hidden="true"></i>
                                    <span>理财等级抢单收益管理</span>
                                </a>
                            </li>
<!--                            <li class="nav-active">-->
<!--                                <a href="/admin/bonus">-->
<!--                                    <i class="fa fa-cny" aria-hidden="true"></i>-->
<!--                                    <span>理财收益比例管理</span>-->
<!--                                </a>-->
<!--                            </li>-->
                            <li class="nav-active">
                                <a href="/admin/product">
                                    <i class="fa fa-bookmark" aria-hidden="true"></i>
                                    <span>理财收益比例管理</span>
                                </a>
                            </li>
                            <li class="nav-active">
                                <a href="/admin/ann?current=1">
                                    <i class="fa fa-comment" aria-hidden="true"></i>
                                    <span>公告管理</span>
                                </a>
                            </li>
                            <li class="nav-active">
                                <a href="/admin/carousel">
                                    <i class="fa fa-th-list" aria-hidden="true"></i>
                                    <span>轮播图管理</span>
                                </a>
                            </li>
<!--                            <li class="nav-active">-->
<!--                                <a href="/admin/pay">-->
<!--                                    <i class="fa fa-btc" aria-hidden="true"></i>-->
<!--                                    <span>收款方式管理</span>-->
<!--                                </a>-->
<!--                            </li>-->
                            <li class="nav-active">
                                <a href="/admin/time">
                                    <i class="fa fa-clock-o" aria-hidden="true"></i>
                                    <span>抢单时段管理</span>
                                </a>
                            </li>
                            <li class="nav-active">
                                <a href="/admin/app">
                                    <i class="fa fa-arrow-down" aria-hidden="true"></i>
                                    <span>APP管理</span>
                                </a>
                            </li>
                        </ul>
                    </nav>

                </div>

            </div>

        </aside>
        <!-- end: sidebar -->

        <section role="main" class="content-body">
            <header class="page-header">
                <h2>会员管理</h2>
                <div class="right-wrapper pull-right">
                    <ol class="breadcrumbs">
                        <li>
                            <a href="/admin/">
                                <i class="fa fa-home"></i>
                            </a>
                        </li>
                        <li><span>会员管理</span></li>
                    </ol>
                </div>
                <div id="userbox2" class="userbox pull-right">
                    <a href="#" data-toggle="dropdown">
                        <figure class="profile-picture">
                            <img th:src="@{/static/imgs/avator.png}" alt="名字" class="img-circle">
                        </figure>
                        <div class="profile-info">
                            <span class="name">张三</span>
                            <span class="role">超级管理员</span>
                        </div>

                        <i class="fa custom-caret"></i>
                    </a>

                    <div class="dropdown-menu">
                        <ul class="list-unstyled">
                            <li class="divider"></li>
                            <li>
                                <a role="menuitem" href="#"><i class="fa fa-user"></i>个人中心</a>
                            </li>
                            <li>
                                <a role="menuitem" href="#"><i class="fa fa-user"></i>系统设置</a>
                            </li>
                            <li>
                                <a role="menuitem" href="/admin/outLogin"><i class="fa fa-user"></i>退出登录</a>
                            </li>
                        </ul>
                    </div>
                </div>
            </header>

            <!-- start: page -->
            <section class="panel">

                <div class="panel-body">
                    <div class="dataTables_wrapper">
                        <div class="table-filter">
                            <form class="form-inline" action="/admin/getUsers" method="get">
                                <input type="hidden" name="current" value="1">
                                <div class="form-group">
                                    <label>用户id</label>
                                    <input type="text" class="form-control" placeholder="用户id" name="id"
                                           autocomplete="off" th:value="${id}" id="userId">
                                </div>
                                <div class="form-group">
                                    <label>手机号</label>
                                    <input type="text" class="form-control" placeholder="手机号" name="mobile"
                                           autocomplete="off" th:value="${mobile}" id="mobile">
                                </div>
                                <div class="form-group">
                                    <label>开始时间</label>
                                    <input type="text" class="form-control" placeholder="注册开始时间" id="datetimeStart"
                                           name="start" autocomplete="off" th:value="${start}">
                                </div>

                                <div class="form-group">
                                    <label>结束时间</label>
                                    <input type="text" class="form-control" placeholder="注册结束时间" id="datetimeEnd"
                                           name="end" autocomplete="off" th:value="${end}">
                                </div>
                                <div class="form-group">
                                    <label>筛选</label>
                                    <select id="type" class="form-control" th:value="${type}" name="type">
                                        <option value="" th:selected="${type}==''">全部</option>
                                        <option value="0" th:selected="${type}=='0'">已封号</option>
                                        <option value="1" th:selected="${type}=='1'">正常</option>
                                        <option value="2" th:selected="${type}=='2'">可以提现</option>
                                        <option value="3" th:selected="${type}=='3'">不可以提现</option>
                                    </select>
                                </div>
                                <button type="submit" class="btn btn-primary"><i class="fa fa-search"></i>搜索</button>
                                <button type="button" class="btn btn-default" onclick="reset1()"
                                        style="margin-left: 30px"><i class="fa fa-trash-o"></i>清空
                                </button>
                            </form>
                        </div>
                        <div class="table-responsive">
                            <table class="table table-bordered table-striped mb-none dataTable table-hover">
                                <thead>
                                <tr>
                                    <th>id</th>
                                    <th>上级id</th>
                                    <th>手机号</th>
                                    <th>昵称</th>
                                    <th>邀请码</th>
                                    <th>充值地址</th>
                                    <th>真实姓名</th>
                                    <th>直推人数</th>
                                    <th>团队人数</th>
                                    <th>今日已抢单数</th>
                                    <th>是否封号</th>
                                    <th>是否可以提现</th>
                                    <th>最近登录时间</th>
                                    <th>注册时间</th>
                                    <th>操作</th>
                                </tr>
                                </thead>
                                <tbody>
                                <tr th:each="user:${list}">
                                    <td th:text="${user.id}"></td>
                                    <td th:text="${user.pid}"></td>
                                    <td th:text="${user.mobile}"></td>
                                    <td th:text="${user.nickname}"></td>
                                    <td th:text="${user.invCode}"></td>
                                    <td th:text="${user.address}"></td>
                                    <td th:text="${user.realName}"></td>
                                    <td th:text="${user.directPushNum}"></td>
                                    <td th:text="${user.teamNum}"></td>
                                    <td th:text="${user.directPushNum}"></td>
                                    <td th:if="${user.state}==0">
                                        <span style="padding:5px 10px; border-radius: 5px; background-color: green;color: #FFF;">
                                            否
                                        </span>
                                    </td>
                                    <td th:if="${user.state}==1">
                                        <span style="padding:5px 10px; border-radius: 5px; background-color: red;color: #FFF;">
                                            是
                                        </span>
                                    </td>
                                    <td th:if="${user.isWithdraw}==1">
                                        <span style="padding:5px 10px; border-radius: 5px; background-color: green;color: #FFF;">
                                            是
                                        </span>
                                    </td>
                                    <td th:if="${user.isWithdraw}==0">
                                        <span style="padding:5px 10px; border-radius: 5px; background-color: red;color: #FFF;">
                                            否
                                        </span>
                                    </td>
                                    <td th:text="${user.loginDate}"></td>
                                    <td th:text="${user.regDate}"></td>
                                    <td>
                                        <a class="mb-xs mt-xs mr-xs modal-basic btn btn-warning" data-toggle="modal"
                                           data-target="#modalWarning" href="javascript:;"
                                           th:onclick="edit([[${user.id}]],[[${user.pid}]],[[${user.mobile}]],[[${user.path}]])">编辑</a>
                                        <!--                                            以下传参方式只支持数字类型-->
                                        <!--                                        th:onclick="'javascript:edit('+${user.id}+','+${user.pid}+',\''+${user.mobile}+'\',\''+${user.loginPwd}+'\',\''+${user.payPwd}+'\',\''+${user.path}+'\','+${user.vipLevel}+');'"-->
                                        <a class="mb-xs mt-xs mr-xs modal-basic btn btn-primary" data-toggle="modal"
                                           data-target="#modalDanger" href="javascript:;" th:if="${user.isWithdraw}==1"
                                           th:onclick="'javascript:assignment('+${user.id}+',0,\'forbidOrLiftForbidWithdraw\');'">禁止提现</a>
                                        <a class="mb-xs mt-xs mr-xs modal-basic btn btn-info" data-toggle="modal"
                                           data-target="#modalSuccess" href="javascript:;" th:if="${user.isWithdraw}==0"
                                           th:onclick="'javascript:assignment('+${user.id}+',1,\'forbidOrLiftForbidWithdraw\');'">恢复提现</a>

                                        <a class="mb-xs mt-xs mr-xs modal-basic btn btn-danger" data-toggle="modal"
                                           data-target="#modalDanger" href="javascript:;" th:if="${user.state}==0"
                                           th:onclick="'javascript:assignment('+${user.id}+',1,\'forbidOrLiftForbidLogin\');'">封号</a>
                                        <a class="mb-xs mt-xs mr-xs modal-basic btn btn-success" data-toggle="modal"
                                           data-target="#modalSuccess" href="javascript:;" th:if="${user.state}==1"
                                           th:onclick="'javascript:assignment('+${user.id}+',0,\'forbidOrLiftForbidLogin\');'">解封</a>

                                    </td>
                                </tr>
                                </tbody>
                            </table>
                        </div>
                        <div class="row datatables-footer">
                            <div class="col-sm-12 col-md-6">
                                <div class="dataTables_info"
                                     th:text="'当前'+${current}+'页,共'+${totalPages}+'页,共'+${totalCount}+'条'">当前
                                    1页，共0页，共0条数据
                                </div>
                            </div>
                            <div class="col-sm-12 col-md-6 text-right">
                                <div class="dataTables_paginate paging_bs_normal">
                                    <ul class="pagination">
                                        <input type="hidden" th:value="${totalPages}" id="totalPages">
                                        <input type="hidden" th:value="${current}" id="current">
                                        <li th:class="${current}==1?'prev disabled':'prev'">
                                            <a th:href="${current}==1?
                                            @{/admin/getUsers(current=${current},id=${id},mobile=${mobile},start=${start},end=${end},type=${type})}
                                            :@{/admin/getUsers(current=(${current}-1),id=${id},mobile=${mobile},start=${start},end=${end},type=${type})}">
                                                <span class="fa fa-chevron-left"></span>
                                            </a>
                                        </li>
                                        <li th:class="${current}==${totalPages}?'next disabled':'next'">
                                            <a th:href="${current}==${totalPages}?
                                            @{/admin/getUsers(current=${totalPages},id=${id},mobile=${mobile},start=${start},end=${end},type=${type})}
                                            :@{/admin/getUsers(current=(${current}+1),id=${id},mobile=${mobile},start=${start},end=${end},type=${type})}">
                                                <span class="fa fa-chevron-right"></span>
                                            </a>
                                        </li>
                                    </ul>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </section>

        </section>
    </div>

</section>

<!--日历-->
<link rel="stylesheet" type="text/css" th:href="@{/static/css/bootstrap-datetimepicker.css}"/>
<script th:src="@{/static/js/bootstrap-datetimepicker.js}" type="text/javascript" charset="utf-8"></script>
<script type="text/javascript" th:src="@{/static/layer/layer.js}"></script>
<script type="text/javascript">
    $("#datetimeStart").datetimepicker({

        format: 'yyyy-mm-dd hh:ii',

        // minView: 'month',

        language: 'zh-CN',

        autoclose: true

        // startDate: new Date()

    }).on("click", function () {

        $("#datetimeStart").datetimepicker("setEndDate", $("#datetimeEnd").val())

    });

    $("#datetimeEnd").datetimepicker({

        format: 'yyyy-mm-dd hh:ii',

        // minView: 'month',

        language: 'zh-CN',

        autoclose: true

        // startDate: new Date()

    }).on("click", function () {

        $("#datetimeEnd").datetimepicker("setStartDate", $("#datetimeStart").val())
    });

    function reset1() {
        $("#userId").val("");
        $("#mobile").val("");
        $("#datetimeStart").val("");
        $("#datetimeEnd").val("");
        $("#type").val("");
    }

    var userId;
    var status;
    var url;

    function assignment(id, type, uri) {
        userId = id;
        status = type;
        url = uri;
    }

    function suc() {
        $.ajax({
            type: 'POST',
            url: '/admin/' + url,
            dataType: 'json',
            data: {
                id: userId,
                state: status
            },
            success: function (res) {
                if (res.code == 200) {
                    layer.msg('成功', {icon: 6});
                    window.location.replace("/admin/getUsers?current=1");
                } else {
                    layer.msg(res.message, {icon: 5});
                }
            }
        });
    }

    function dan() {
        $.ajax({
            type: 'POST',
            url: '/admin/' + url,
            dataType: 'json',
            data: {
                id: userId,
                state: status
            },
            success: function (res) {
                if (res.code == 200) {
                    layer.msg('成功', {icon: 6});
                    window.location.replace("/admin/getUsers?current=1");
                } else {
                    layer.msg(res.message, {icon: 5});
                }
            }
        });
    }

    function edit(id, pid, mobile, path) {
        $("#edit_userId").val(id);
        $("#edit_pId").val(pid);
        $("#edit_mobile").val(mobile);
        $("#edit_path").val(path);
    }

    function edit_sub() {
        var id = $("#edit_userId").val();
        var pid = $("#edit_pId").val();
        var mobile = $("#edit_mobile").val();
        var loginPwd = $("#edit_login_pwd").val();
        var payPwd = $("#edit_pay_pwd").val();
        var path = $("#edit_path").val();
        if (pid != null && pid != '') {
            if (path == null || path == '') {
                layer.msg('请填写推荐关系', {icon: 5});
                return false;
            }
        } else {
            if (path != null && path != '') {
                layer.msg('请填写上级id', {icon: 5});
                return false;
            }
        }
        $.ajax({
            type: 'POST',
            url: '/admin/editUser',
            dataType: 'json',
            data: {
                id: id,
                pid: pid,
                mobile: mobile,
                loginPwd: loginPwd,
                payPwd: payPwd,
                path: path
            },
            success: function (res) {
                if (res.code == 200) {
                    layer.msg('成功', {icon: 6});
                    window.location.replace("/admin/getUsers?current=1");
                } else {
                    layer.msg(res.method, {icon: 5});
                }
            }
        });
    }


</script>

<!--弹出框-->
<div id="modalWarning" class="modal-box modal-block-warning modal fade" tabindex="-1" role="dialog" aria-labelledby="">
    <section class="panel">
        <header class="panel-heading">
            <h2 class="panel-title">编辑</h2>
        </header>
        <div class="panel-body">
            <div class="modal-wrapper">
                <div class="form-horizontal">
                    <div class="form-group">
                        <label class="col-sm-2 control-label">用户id</label>
                        <div class="col-sm-8">
                            <input type="text" class="form-control" disabled="disabled" id="edit_userId" name="id">
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-2 control-label">上级id</label>
                        <div class="col-sm-8">
                            <input type="number" class="form-control" id="edit_pId" name="pId">
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-2 control-label">手机号</label>
                        <div class="col-sm-8">
                            <input type="tel" class="form-control" placeholder="请输入手机号" maxlength="11" id="edit_mobile"
                                   name="mobile">
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-2 control-label">登录密码</label>
                        <div class="col-sm-8">
                            <input type="password" class="form-control" placeholder="请输入登陆密码" id="edit_login_pwd"
                                   name="loginPassword">
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-2 control-label">交易密码</label>
                        <div class="col-sm-8">
                            <input type="password" class="form-control" placeholder="请输入交易密码" id="edit_pay_pwd"
                                   name="payPassword">
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-2 control-label">推荐关系</label>
                        <div class="col-sm-8">
                            <textarea type="text" class="form-control" placeholder="请输入推荐关系" id="edit_path"
                                      name="path"></textarea>
                        </div>
                    </div>
<!--                    <div class="form-group">-->
<!--                        <label class="col-sm-2 control-label">VIP等级</label>-->
<!--                        <div class="col-sm-8">-->
<!--                            <input type="number" class="form-control" placeholder="请输入VIP等级" value="0"-->
<!--                                   id="edit_vip_level"-->
<!--                                   name="vipLevel">-->
<!--                        </div>-->
<!--                    </div>-->
                    <!--                    <div class="form-group">-->
                    <!--                        <label class="col-sm-2 col-xs-12 control-label">验证码</label>-->
                    <!--                        <div class="col-sm-6 col-xs-8">-->
                    <!--                            <input type="tel" class="form-control" placeholder="请输入手机短信中的6位验证码" maxlength="6">-->
                    <!--                        </div>-->
                    <!--                        <div class="col-sm-4  col-xs-4 text-right">-->
                    <!--                            <button type="button" class="btn btn-default">发送验证码</button>-->
                    <!--                        </div>-->
                    <!--                </div>-->
                </div>
            </div>
        </div>
        <footer class="panel-footer">
            <div class="row">
                <div class="col-md-12 text-right">
                    <button class="btn btn-primary modal-confirm" type="button" onclick="edit_sub()">提交</button>
                    <button class="btn btn-default modal-dismiss" data-dismiss="modal">取消</button>
                </div>
            </div>
        </footer>
    </section>
</div>
<div id="modalSuccess" class="modal-box modal-block-success modal fade" tabindex="-1" role="dialog" aria-labelledby="">
    <section class="panel">
        <header class="panel-heading">
            <h2 class="panel-title">友情提示</h2>
        </header>
        <div class="panel-body">
            <div class="modal-wrapper">
                <div class="modal-icon">
                    <i class="fa fa-check"></i>
                </div>
                <div class="modal-text">
                    <h4>操作提示</h4>
                    <p>确定要进行此操作吗？</p>
                </div>
            </div>
        </div>
        <footer class="panel-footer">
            <div class="row">
                <div class="col-md-12 text-right">
                    <button class="btn btn-primary modal-confirm" onclick="suc()">确定</button>
                    <button class="btn btn-default modal-dismiss" data-dismiss="modal">取消</button>
                </div>
            </div>
        </footer>
    </section>
</div>

<div id="modalDanger" class="modal-box modal-block-danger modal fade" tabindex="-1" role="dialog" aria-labelledby="">
    <section class="panel">
        <header class="panel-heading">
            <h2 class="panel-title">友情提示</h2>
        </header>
        <div class="panel-body">
            <div class="modal-wrapper">
                <div class="modal-icon">
                    <i class="fa fa-times-circle"></i>
                </div>
                <div class="modal-text">
                    <h4>操作提示</h4>
                    <p>确定要进行此操作吗？</p>
                </div>
            </div>
        </div>
        <footer class="panel-footer">
            <div class="row">
                <div class="col-md-12 text-right">
                    <button class="btn btn-primary modal-confirm" onclick="dan()">确定</button>
                    <button class="btn btn-default modal-dismiss" data-dismiss="modal">取消</button>
                </div>
            </div>
        </footer>
    </section>
</div>
</body>

</body>

</html>